home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d18 / intrfc4.arc / INTRFC.DOC < prev    next >
Text File  |  1990-12-23  |  6KB  |  135 lines

  1. INTRFC - Program to print interface information for TPU files.
  2. (May, 1988; minor changes, July, 1988)
  3.  
  4. Written for the public domain by D.J. Murdoch (CIS 71631,122 or
  5. Fidonet 1:221/177.40 "DJ Murdoch")
  6.  
  7. INTRODUCTION
  8.  
  9.      I started INTRFC because I got a library of Turbo Pascal 4.0
  10. subroutines from a bulletin board which had some errors in the
  11. documentation.  One of the functions wanted its arguments to be a
  12. special type, but the doc's didn't tell me which one.  TP gave me
  13. an error message saying I wasn't using the right type, but
  14. wouldn't tell me which one to use either.  I decided to decode
  15. the TPU file and figure out what TP wanted.  Once I got started,
  16. it was hard to stop.  So, I ended up writing INTRFC, which prints
  17. out almost all the information you'll ever need about the
  18. interface to a TPU unit.  (You can also get information about
  19. units in TPL's; use TPUMOVER to move them out into a TPU first.)
  20.  
  21.      Because of the way it was written, i.e. entirely by
  22. guesswork, I'm sure there are numerous special cases that it
  23. doesn't handle properly.  That's one reason the source code is
  24. there - so other people can fix up my mistakes.
  25.  
  26.      The other reason I included source code is because it will
  27. serve as a bit of documentation for the TPU file format while we
  28. all wait for Borland to publish it.  (I imagine they want to be
  29. free to change the format before they publish it, making INTRFC
  30. obsolete when TP 4.1 arrives.)  Others who want to do completely
  31. different things to a TPU file may benefit from reading it.  (The
  32. other difficulty with a program written the way this one was is
  33. that comments are almost non-existent.  If you have any short
  34. questions about it that you can't figure out, send them to me at
  35. one of the addresses above.)
  36.  
  37. USAGE:  INTRFC [unit path]
  38.  
  39.      The user interface (sorry!) to INTRFC is really primitive.
  40. Just run it without any arguments, and answer the prompt for a
  41. unit.  Don't type the ".TPU".  It expects to find any referenced
  42. (i.e. USE'd) units in the current directory.  Or, if you like,
  43. specify a path on the command line where it can find the other
  44. units.  (It needs to look in them for names and types sometimes).
  45. This path should also contain the TURBO.TPL file containing the
  46. system units.
  47.  
  48.     After it prints the interface to the unit you specify, it
  49. will ask for another one.  To quit, you'll have to hit break or
  50. Ctrl-C. (F6 or Ctrl-Z might also work, by crashing it.)  Both
  51. input and output can be redirected using "<" and ">".  (Watch out
  52. though, the prompts get redirected too.  I warned you it was
  53. primitive.)
  54.  
  55. TPU STRUCTURE
  56.  
  57.     Below are some notes on the general structure of a TPU file.
  58. For more detail, see the source code.  When I named something
  59. there with a totally obscure name (like i1, or ofs1) it generally
  60. meant that I don't have any idea what it was for.
  61.  
  62.     There are four parts to a TPU file - the symbol area, the
  63. code area, the relocation area, and the data area.  (TPUMOVER
  64. will tell you how big each is.)  INTRFC only looks at the symbol
  65. area.
  66.  
  67.     At the start of it, there's a table giving sizes and offsets
  68. of important parts of the file.  Most important is the hash table
  69. - it gives the addresses (16 bit pointers) of many of the objects
  70. that are defined in the interface block.  (The hash function
  71. seems to be a simple one.  Letters A-Z and a-z get mapped to 0-
  72. 25, underscores and digits get their ascii codes, and longer
  73. strings get the sum of the codes of their characters, modulo the
  74. table size).  In case of a collision (i.e. hash(object 1) =
  75. hash(object 2) ), there's a pointer at the beginning of each
  76. object to the next one with the same hash value.
  77.  
  78.     Things being defined are stored in variations on 2 or 3
  79. kinds of record.  The main storage is as what I call an Object.
  80. This gives a pointer to the next object with the same hash
  81. number, the name of the object, and is followed by the
  82. Information.  The Information defines what "kind" of object this
  83. is, i.e. a variable, type, constant, etc.  It also gives some
  84. information about the object, often including references to the
  85. third kind of record, the Type Definitions.  These are like
  86. Information records, subdividing the various types, e.g. array,
  87. string, set, etc.
  88.  
  89.     All variables have an offset.  If they are part of a record,
  90. this is the offset within the record.  If not, then I assume
  91. these are the offsets in the data segment (but haven't checked).
  92.  
  93. TPL STRUCTURE
  94.  
  95.     TPL files have a very simple structure.  They seem to be just
  96. a collection of TPU files strung together.  (The header might be
  97. slightly varied; I'm not sure.)
  98.  
  99.     Borland provides the TPUMOVER program which can extract TPU
  100. files from TPL files.  Either use the command line /* option or
  101. mark the unit you want in full-screen mode and use INS to extract
  102. it.
  103.  
  104. LIMITATIONS
  105.  
  106.     There are tons of limitations to INTRFC.  It doesn't know how
  107. to print any but the simplest types of constants.  It won't print
  108. the values of typed constants.  It won't read files bigger than
  109. 64K.  Etc. Etc. Etc.  If you want it to do something differently
  110. just go ahead and change it!  I recommend compiling with all
  111. possible checks turned on, since it's pretty easy to get lost in
  112. all those pointers.
  113.  
  114. FILES
  115.  
  116. The following files should be included in this package.
  117.  
  118. INTRFC.DOC      - This file.
  119. INTRFC.EXE      - The executable program.
  120. GLOBALS.PAS     - The global declarations.
  121. HASH.PAS        - The routines to walk through the hash table, and
  122.                   to get units
  123. INTRFC.PAS      - The main program.
  124. OBJSTUFF.PAS    - The various routines for printing objects.
  125. TEST1.PAS       - A test unit.
  126. UTIL.PAS        - Various utility routines.
  127.  
  128. THAT'S IT!
  129.  
  130.      Have fun with INTRFC and Turbo Pascal.  I'd like to hear of
  131. any novel uses.
  132.  
  133. D.J. Murdoch
  134.  
  135.